package com.msb.filterandlistrer.filtertest;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/** 过滤器测试
 * @author LiuShanshan
 * @version V1.0
 * @Description
 */
@Order(1)   // order里面的值越低，越先执行
@WebFilter(urlPatterns = "/api/filter/*", filterName = "FilterDemo1")
public class FilterDemo1 implements Filter{
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        // 容器加载的时候执行
        System.out.println("过滤器进入========================");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        // 请求被拦截时请求
        System.out.println("请求拦截中=====================================");

    }

    @Override
    public void destroy() {
        // 容器销毁的时候执行
        System.out.println("过滤器销毁=======================");
    }
}
